import { defineStore } from "pinia";
import { ApplicationItem } from "/@/api/models";

interface LoadingParams {
  loading: boolean;
  text?: string;
}

export const useHomeStore = defineStore("home", {
  state: (): {
    loading: boolean;
    loadingText: string;
    pageLoading: boolean;
    contentScrollable: boolean;
    applicationData: ApplicationItem[];
  } => {
    return {
      loading: false,
      loadingText: "",
      pageLoading: false,
      contentScrollable: true,
      applicationData: [
        {
          id: 1,
          code: "main",
          url: "/main",
        },
      ],
    };
  },
  actions: {
    toggleLoading(params: LoadingParams) {
      this.loading = params.loading;
      this.loadingText = params.text || "";
    },
    togglePageLoading(params: LoadingParams) {
      this.pageLoading = params.loading;
    },
  },
});
